import Vue from 'vue'
import VueRouter from 'vue-router'

// 添加这个Login组件
import Login from '../components/Login.vue'
// import Welcome from '../components/common/Welcome.vue'
import Home from '../components/Home.vue'
import UpdatePassword from '../components/common/UpdatePassword.vue'

//admin下面的两个功能
import UserManage from '../components/admin/UserManage.vue'




// 现在修改的版本，就是直接
import AssociationShow from '../components/association/AssociationShow.vue'
import AExp1Show from '../components/association/exp1/Exp1Show.vue'
import AExp1DataSet from '../components/association/exp1/Exp1DataSet.vue'
import AExp1Answer from '../components/association/exp1/Exp1Anwser.vue'


import AExp2Show from '../components/association/exp2/Exp2Show.vue'
import AExp2DataSet from '../components/association/exp2/Exp2DataSet.vue'
import AExp2OtherData from '../components/association/exp2/Exp2OtherData.vue'
import AExp2Answer from '../components/association/exp2/Exp2Anwser.vue'
import AExp2Detail from '../components/association/exp2/Exp2Detail.vue'

import ClusterShow from '../components/cluster/ClusterShow.vue'
import BExp1Show from '../components/cluster/exp1/Exp1Show.vue'
import BExp1DataShow from '../components/cluster/exp1/Exp1DataSet.vue'
import BExp1Kmeans from '../components/cluster/exp1/Exp1Kmeans.vue'
import BExp1Dbscan from '../components/cluster/exp1/Exp1Dbscan.vue'


import BExp2Show from '../components/cluster/exp2/Exp2Show.vue'


import ClassificationShow from '../components/classification/ClassificationShow.vue'
import CExp1Show from '../components/classification/exp1/Exp1Show.vue'
import CExp1DataShow from '../components/classification/exp1/Exp1DataShow.vue'
import CExp1resultPic from '../components/classification/exp1/Exp1DecisionTree.vue'


import RegressionShow from '../components/regression/RegressionShow.vue'
import DExp1Show from '../components/regression/exp1/Exp1Show.vue'
import DExp1DataShow from '../components/regression/exp1/Exp1DataShow.vue'
import DExp1Result1 from '../components/regression/exp1/Exp1Result1.vue'
import DExp1Result2 from '../components/regression/exp1/Exp1Result2.vue'







Vue.use(VueRouter)

const routes = [{
    path: '/',
    component: Login
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/home',
    component: Home,
    redirect: '/association',
    children: [
      {
        path: '/association',
        component: AssociationShow
      },
      {
        path: '/aExp1Show',
        component: AExp1Show,
      },
      {
        path: '/aExp1DataShow',
        component: AExp1DataSet,
      },
      {
        path: '/aExp1DataAnswer',
        component: AExp1Answer,
      },


      {
        path: '/aExp2Show',
        component: AExp2Show
      },

      {
        path: '/aExp2DataShow',
        component: AExp2DataSet
      },
      {
        path: '/aExp2OtherData',
        component: AExp2OtherData
      },
      {
        path: '/aExp2Pic',
        component: AExp2Answer
      },
      {
        path: '/aExp2Detail',
        component: AExp2Detail
      },







      {
        path: '/cluster',
        component: ClusterShow
      },
      {
        path: '/bExp1Show',
        component: BExp1Show
      },
      {
        path: '/bExp1DataShow',
        component: BExp1DataShow
      },
      {
        path: '/bExp1Kmeans',
        component: BExp1Kmeans
      },
      {
        path: '/bExp1Dbscan',
        component: BExp1Dbscan
      },








      {
        path: '/bExp2Show',
        component: BExp2Show
      },


      {
        path: '/classification',
        component: ClassificationShow
      },
      {
        path: '/cExp1Show',
        component: CExp1Show
      },
      {
        path: '/cExp1DataShow',
        component: CExp1DataShow
      },
      {
        path: '/cExp1ResultPic',
        component: CExp1resultPic
      },



      {
        path: '/regression',
        component: RegressionShow
      },
      {
        path: '/dExp1Show',
        component: DExp1Show
      },
      {
        path: '/dExp1DataShow',
        component: DExp1DataShow
      },
      {
        path: '/dExp1Pic1',
        component: DExp1Result1
      },
      {
        path: '/dExp1Pic2',
        component: DExp1Result2
      },
 
















      {
        path: '/updatePassword',
        component: UpdatePassword
      },
      {
        path: '/userManage',
        component: UserManage
      },



    ]
  },

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to, from, next) => {
  //to 将要访问
  //from 从哪进行访问
  //next 重定向这个url next() 继续访问。to的路径
  if (to.path == '/login') return next(); //如果是访问这个login，那么就放行，然后执行之后的操作，也就是说这个是首页
  const userFlag = window.sessionStorage.getItem("user"); //如果不是首页，那么就判断这个信息是不是有这个sessionStorage里面进行判断，
  if (!userFlag) { //没有这个信息
    return next('/login') //转到登录的地方去，无值返回到登陆页面    //如果没有，那么就到登录的页面
  }
  next(); //有值，那么就直接进行放行
})





export default router